<template>
  <div class="search">
    <!-- 发布商家开始 -->
    <Row style="margin-bottom: 20px" v-if="siteShow">
      <Col>
        <Card>
          <Row>
            <Col :span="5">
              <Button @click="getList" icon="md-refresh" style="margin-right:10px">刷新</Button>
              <Button @click="showAddModal" type="primary" icon="md-add">添加</Button>
            </Col>
            <Col :span="19">
              <Form ref="searchForm" inline :model="searchForm" :label-width="85">
                <FormItem label="商品分类" v-if="service !='四大金刚'">
                  <Poptip trigger="click" placement="right-start" title="分类" width="100%">
                    <Input v-model="searchForm.goodCategoryName" style="width:100%" readonly placeholder="请选择商品分类" />
                    <div slot="content" style="position:relative;min-height:5vh">
                      <Tree :data="classifyData" :load-data="loadData" @on-select-change="selectOneTreeEdit" ref="treeOne"></Tree>
                      <Spin size="large" fix v-if="loadingEdit"></Spin>
                    </div>
                  </Poptip>
                </FormItem>
                <FormItem label="商品名称">
                  <Input v-model="searchForm.goodName" clearable placeholder="请输入商品名称" class="itemInput" />
                </FormItem>
                <Form-item style="margin-left:-40px">
                  <Button type="default" @click="clearIpt" style="margin-right:10px">清空</Button>
                  <Button type="primary" @click="getList" style="margin-right:10px">搜索</Button>
                </Form-item>
              </Form>
            </Col>
          </Row>
          <Row>
            <Table :loading="loading" border :columns="commodityColumns" :data="commodityData" ref="table" sortable="custom" @on-sort-change="changeSort"></Table>
          </Row>

          <Row type="flex" justify="end" class="page">
            <Page :current="searchForm.pageNumber" :total="pageTotal" :page-size="searchForm.pageSize" @on-change="changePage" @on-page-size-change="changePageSize" :page-size-opts="[10,20,50]" size="small" show-total show-elevator show-sizer></Page>
          </Row>
        </Card>
      </Col>
    </Row>
    <!-- 发布商家结束 -->

    <!-- 发布场地开始 -->
    <Row style="margin-bottom: 20px" v-if="!siteShow">
      <Col>
        <Card>
          <Row style="margin-bottom: 20px">
            <Col :span="5">
              <Button @click="getList" icon="md-refresh" style="margin-right:10px">刷新</Button>
              <Button @click="showAddModal" type="primary" icon="md-add">添加</Button>
            </Col>
          </Row>
          <Row>
            <Table :loading="loading" border :columns="columns" :data="data" ref="table" sortable="custom" @on-sort-change="changeSort"></Table>
          </Row>

          <Row type="flex" justify="end" class="page">
            <Page :current="searchForm.pageNumber" :total="total" :page-size="searchForm.pageSize" @on-change="changePage" @on-page-size-change="changePageSize" :page-size-opts="[10,20,50]" size="small" show-total show-elevator show-sizer></Page>
          </Row>
        </Card>
      </Col>
    </Row>
    <!-- 发布场地结束 -->

    <!-- 查看大图 -->
    <Modal title="查看大图" v-model="visible" class="imgModal">
      <img :src="imgSrc" style="width: 100%" />
    </Modal>
    <!-- 添加商品 -->
    <Modal :title="modalTitle" v-model="modalVisible" :mask-closable="false" :width="800">
      <Form ref="addForm" :model="addForm" :label-width="100" :rules="formRules">
        <FormItem label="商品名称" prop="goodName">
          <Input v-model="addForm.goodName" placeholder="请输入商品名称" />
        </FormItem>
        <FormItem label="商品分类" prop="goodCategoryId" v-if="service !='四大金刚'">
          <Poptip trigger="click" placement="right-start" title="分类" width="100%">
            <Input v-model="addForm.goodCategoryName" style="width:100%" readonly placeholder="请选择商品分类" />
            <div slot="content" style="position:relative;min-height:5vh">
              <Tree :data="classifyData" :load-data="loadData" @on-select-change="selectTwoTreeEdit" ref="treeTwo"></Tree>
              <Spin size="large" fix v-if="loadingEdit"></Spin>
            </div>
          </Poptip> 
        </FormItem>
        <FormItem label="商品原价" prop="goodOldPrice">
          <Input v-model="addForm.goodOldPrice" placeholder="请输入商品原价" />
        </FormItem>
        <FormItem label="商品现价" prop="goodNewPrice">
          <Input v-model="addForm.goodNewPrice" placeholder="请输入商品现价" />
        </FormItem>
        <FormItem label="商品轮播图片" prop="goodPics">
          <upload-pic-thumb @on-change="addForm.goodPics=$event" ref="picsUpload" style="width:100%"></upload-pic-thumb>
        </FormItem>
        <FormItem label="商品视频展示图" prop="goodVideoPic">
          <upload-pic-input v-model="addForm.goodVideoPic" style="width:100%"></upload-pic-input>
        </FormItem>
        <FormItem label="商品视频">
          <upload-video v-model="addForm.goodVideo" style="width:100%"></upload-video>
        </FormItem>
        <FormItem label="商品详情">
          <editor id="editor" v-model="addForm.goodDetails" ref="editor"></editor>
        </FormItem>
      </Form>
      <div slot="footer">
        <Button type="text" @click="cancel">取消</Button>
        <Button type="primary" @click="handleSubmit('form')">提交</Button>
      </div>
    </Modal>

    <!-- 规格列表 -->
    <Modal title="商品规格" v-model="lookPreVisible" :mask-closable='false' :width="850">
      <Button type="primary" @click="addSpecification">添加</Button>
      
      <Row style="margin-top:30px;">
        <Table :loading="loading" border :columns="specificationColumns" :data="specificationData"  ref="table" sortable="custom" @on-sort-change="changeSort" @on-selection-change="changeSelect"></Table>
      </Row>
      <Row type="flex" justify="end" class="page">
        <Page :current="searchForm.pageNumber" :total="1" :page-size="searchForm.pageSize" @on-change="changePage" @on-page-size-change="changePageSize" :page-size-opts="[10,20,50]" size="small" show-total show-elevator show-sizer></Page>
      </Row>
    </Modal>

    <!-- 商品规格添加 -->
    <Modal title="商品规格" v-model="preVisible" :mask-closable='false' :width="600" @on-cancel="cancelModal">
      <Form ref="preForm" :model="preForm" :label-width="100" :rules="preFormValidate" >
        <FormItem label="规格图片" prop="pic" >
         <upload-pic-input v-model="preForm.pic" style="width:100%"></upload-pic-input>
        </FormItem>
        <FormItem label="规格" prop="attrSymbolPath" v-if="modalStatus === 0">
          <i-select style="width:30%" v-for="(row, index) in specificationlist" :key="row.id" @on-change="selectSpecification($event, index)">
            <i-option v-for="item in row.children" :key="item.id" :value="item.id" @click="getAttrIds(item)">{{item.title}}</i-option>
          </i-select>
        </FormItem>
        <FormItem label="价格" prop="goodPrice" >
          <Input v-model="preForm.goodPrice" style="width:100%" />
        </FormItem>
        <FormItem label="库存" prop="inventory" >
          <InputNumber v-model="preForm.inventory" style="width:100%"></InputNumber>
        </FormItem>
        <FormItem label="租赁定金" prop="goodDeposit" v-if="buyState != 1">
          <Input v-model="preForm.goodDeposit" style="width:100%" />
        </FormItem>
        <!-- <FormItem label="租赁尾款" prop="goodDalancePayment" v-if="buyState != 1">
          <Input v-model="preForm.goodDalancePayment" style="width:100%" />
        </FormItem> -->
      </Form>
      <div slot="footer">
        <Button type="text" @click="cancelModal">取消</Button>
        <Button type="primary" :loading="submitLoading" @click="preHandleSubmit" >提交</Button>
      </div>
    </Modal>

    <!-- 商品服务列表 -->
    <Modal title="商品服务" v-model="lookServiceVisible" :mask-closable='false' :width="600">
      <Row>
        <Button type="primary" @click="addService">添加</Button>
      </Row>
      
      <Row style="margin-top:30px;">
        <Table :loading="loading" border :columns="seiviceColumns" :data="serviceData"  ref="table" sortable="custom" @on-sort-change="changeSort"></Table>
      </Row>
    </Modal>

    <Modal title="商品服务" v-model="serviceVisible" :mask-closable='false' :width="600">
      <Form ref="serviceForm" :model="serviceForm" :label-width="100" :rules="serviceFormValidate" >
        <FormItem label="服务名称" prop="serverName" >
          <Input v-model="serviceForm.serverName" style="width:45%" placeholder="请输入商品服务名称" />
          <Select style="width:45%;margin-left: 5%;" v-model="serviceForm.serverName" filterable>
            <Option v-for="item in publicData" :key="item.id" :value="item.serverName">{{item.serverName}}</Option>
          </Select>
        </FormItem>
      </Form>
      <div slot="footer">
        <Button type="text" @click="serviceVisible=false">取消</Button>
        <Button type="primary" :loading="submitLoading" @click="serviceHandleSubmit" >提交</Button>
      </div>
    </Modal>

    <!-- 评论列表 -->
    <Modal title="商品评论" v-model="commentVisible" :mask-closable='false' :width="1100">
      <Row style="margin-top:30px;">
        <Table :loading="loading" border :columns="commentColumns" :data="commentData"  ref="table" sortable="custom" @on-sort-change="changeSort"></Table>
      </Row>
    </Modal>

    <Modal title="回复评论" v-model="replyVisible" :mask-closable='false' :width="900">
      <Form ref="replyForm" :model="replyForm" :label-width="100" :rules="replyFormValidate" >
        <FormItem label="回复内容" prop="content" >
          <Input v-model="replyForm.content" style="width:100%" placeholder="请输入回复内容" type="textarea" />
        </FormItem>
      </Form>
      <div slot="footer">
        <Button type="text" @click="replyVisible=false">取消</Button>
        <Button type="primary" :loading="submitLoading" @click="replyHandleSubmit">提交</Button>
      </div>
    </Modal>

    <Modal :title="siteTitle" v-model="siteVisible" :mask-closable='false' :width="900">
      <Form ref="siteForm" :model="siteForm" :label-width="100" :rules="formValidate" >
        <FormItem label="场地名称" prop="siteName" >
          <Input v-model="siteForm.siteName" style="width:100%" placeholder="请输入场地名称" type="text" />
        </FormItem>
        <FormItem label="商品分类" prop="categoryId">
          <Poptip trigger="click" placement="right-start" title="分类" width="100%">
            <Input v-model="siteForm.goodCategoryName" style="width:100%" readonly placeholder="请选择场地分类" />
            <div slot="content" style="position:relative;min-height:5vh">
              <Tree :data="classifyData" :load-data="loadData" @on-select-change="selectSiteEdit" ref="treeTwo"></Tree>
              <Spin size="large" fix v-if="loadingEdit"></Spin>
            </div>
          </Poptip> 
        </FormItem>
        <!-- <FormItem label="场地名称" prop="siteName" >
          <Input v-model="siteForm.siteName" style="width:100%" placeholder="请输入场地名称" type="text" />
        </FormItem> -->
        <FormItem label="场地规格参数" prop="siteItemValue" v-if="modalType == 'add'">
          <i-select style="width:30%" v-for="(row, index) in siteSpecifitionlist" @on-change="selectSite($event, index)" :key="row.id">
            <i-option v-for="item in row.children" :key="item.id" :value="item.id" @click="getAttrIds(item)">{{item.title}}</i-option>
          </i-select>
        </FormItem>
        <FormItem label="场地价格" prop="sitePrice" >
          <Input v-model="siteForm.sitePrice" style="width:100%" placeholder="请输入场地价格" type="text" />
        </FormItem>
        <FormItem label="场地介绍图片" prop="sitePics">
          <upload-pic-thumb @on-change="siteForm.sitePics=$event" v-model="siteForm.sitePics" ref="sitesUpload" style="width:100%"></upload-pic-thumb>
        </FormItem>
      </Form>
      <div slot="footer">
        <Button type="text" @click="siteVisible=false">取消</Button>
        <Button type="primary" :loading="submitLoading" @click="siteHandleSubmit">提交</Button>
      </div>
    </Modal>

    <Modal title="无档期时间" v-model="timeVisible" :mask-closable='false' :width="1100">
      <Row>
        <Button type="primary" @click="addTime">添加</Button>
      </Row>
      <Row style="margin-top:30px;">
        <Table :loading="loading" border :columns="timeColumns" :data="timeData"  ref="table" sortable="custom" @on-sort-change="changeSort"></Table>
      </Row>
    </Modal>

    <Modal :title="timeTitle" v-model="setVisible" :mask-closable='false' :width="900">
      <Form ref="timeForm" :model="timeForm" :label-width="100" :rules="timeFormValidate" >
        <FormItem label="无档期日期" prop="noScheduleTime" >
          <Date-picker type="date" placeholder="选择日期" style="width: 100%" @on-change="changeSetTime" :value="timeForm.noScheduleTime" :options="options3"></Date-picker>
        </FormItem>
        <FormItem label="档期段" prop="dayTimeType">
          <Select style="width:100%" v-model="timeForm.dayTimeType">
            <Option value="A_M">上午</Option>
            <Option value="P_M">下午</Option>
          </Select>
        </FormItem>
      </Form>
      <div slot="footer">
        <Button type="text" @click="setVisible=false">取消</Button>
        <Button type="primary" :loading="submitLoading" @click="setHandleSubmit">提交</Button>
      </div>
    </Modal>

    <!-- 特殊节日 -->
    <Modal title="特殊节日" v-model="specialVisible" :mask-closable='false' :width="1100">
      <Row>
        <Button type="primary" @click="addSpecialFesitval">添加</Button>
      </Row>
      <Row style="margin-top:30px;">
        <Table :loading="loading" border :columns="specialFestivalColumns" :data="specialFestivalData"  ref="table" sortable="custom" @on-sort-change="changeSort"></Table>
      </Row>
      <Row type="flex" justify="end" class="page">
        <Page :current="festivalForm.pageNumber" :total="specialTotal" :page-size="festivalForm.pageSize" @on-change="changeFestivalPage" @on-page-size-change="changeFestivalPageSize" :page-size-opts="[10]" size="small" show-total show-elevator show-sizer></Page>
      </Row>
    </Modal>

    <!-- 特殊节日 -->
    <Modal :title="festivalTitle" v-model="addSpecialVisible" :mask-closable='false' :width="900">
      <Form ref="specialFestivalForm" :model="specialFestivalForm" :label-width="100" :rules="specialFestivalRules" >
        <FormItem label="特殊节日日期" prop="scheduleTime">
          <Date-picker type="date" placeholder="选择日期" style="width: 100%" @on-change="changeSpecialTime" :value="specialFestivalForm.scheduleTime" :options="options3"></Date-picker>
        </FormItem>
        <FormItem label="特殊节日价格" prop="goodsPrice">
          <Input v-model="specialFestivalForm.goodsPrice" style="width: 100%" placeholder="请输入特殊节日价格" />
        </FormItem>
      </Form>
      <div slot="footer">
        <Button type="text" @click="addSpecialVisible=false">取消</Button>
        <Button type="primary" :loading="submitLoading" @click="specialHandleSubmit">提交</Button>
      </div>
    </Modal>

    <!-- 四大金刚无档期 -->
    <Modal title="无档期" v-model="presideVisible" :mask-closable='false' :width="1100">
      <Row>
        <Button type="primary" @click="addPreside">添加</Button>
      </Row>
      <Row style="margin-top:30px;">
        <Table :loading="loading" border :columns="presideColumns" :data="presideData"  ref="table" sortable="custom" @on-sort-change="changeSort"></Table>
      </Row>
    </Modal>

    <!-- 四大金刚无档期 -->
    <Modal :title="presideTitle" v-model="addPresideVisible" :mask-closable='false' :width="900">
      <Form ref="presideForm" :model="presideForm" :label-width="100" :rules="presideRules" >
        <FormItem label="特殊节日日期" prop="noScheduleTime">
          <Date-picker type="date" placeholder="选择日期" style="width: 100%" @on-change="changeRresideTime" :value="presideForm.noScheduleTime" :options="options3"></Date-picker>
        </FormItem>
        <FormItem label="特殊节日时间段" prop="dayTimeType" >
          <Select v-model="presideForm.dayTimeType" style="width: 100%">
            <Option value="A_M">上午</Option>
            <Option value="P_M">下午</Option>
          </Select>
        </FormItem>
      </Form>
      <div slot="footer">
        <Button type="text" @click="addPresideVisible=false">取消</Button>
        <Button type="primary" :loading="submitLoading" @click="presideHandleSubmit">提交</Button>
      </div>
    </Modal>

    <Modal title="场地档期时间" v-model="calendarVisible" :mask-closable='false' :width="1100">
      <Row>
        <Button type="primary" @click="addCalendar">添加</Button>
      </Row>
      <Row style="margin-top:30px;">
        <Table :loading="loading" border :columns="calendarColumns" :data="calendarData"  ref="table" sortable="custom" @on-sort-change="changeSort"></Table>
      </Row>
    </Modal>

    <Modal :title="calendarTitle" v-model="setCalendarVisible" :mask-closable='false' :width="900">
      <Form ref="calendarForm" :model="calendarForm" :label-width="100" :rules="calendarFormRules" >
        <FormItem label="档期日期" prop="scheduleTime" >
          <Date-picker type="date" placeholder="选择日期" style="width: 100%" @on-change="changeSetCalendar" :value="calendarForm.scheduleTime" :options="options3"></Date-picker>
        </FormItem>
        <FormItem label="档期价格" prop="sitePrice">
          <Input v-model="calendarForm.sitePrice" style="width: 100%" placeholder="请输入档期价格" />
        </FormItem>
      </Form>
      <div slot="footer">
        <Button type="text" @click="setCalendarVisible=false">取消</Button>
        <Button type="primary" :loading="submitLoading" @click="calendarSubmit">提交</Button>
      </div>
    </Modal>

    <Modal
      v-model="videoVisible"
      title="视频播放"
      :width="600"
      @on-cancel="closeVideo"
      draggable
    >
      <div id="dplayer" style="height: 500px"></div>
    </Modal>
  </div>
</template>

<script>
import { validateName } from "@/libs/validate";
import "dplayer/dist/DPlayer.min.css";
import DPlayer from "dplayer";
var dp;
import {
  getCategoryList,
  getCommodityList,
  editCommodity,
  removeCommodity,
  addCommodity,
  getColorList,
  getSizeList
} from "@/api/commodity";
import uploadPicThumb from "@/views/my-components/xboot/upload-pic-thumb";
import uploadPicInput from "@/views/my-components/xboot/upload-pic-input";
import uploadVideo from "@/views/my-components/xboot/upload-video"
import editor from "@/views/my-components/xboot/editor";
export default {
  components: {
    uploadPicThumb,
    uploadPicInput,
    editor,
    uploadVideo
  },
  data() {
    return {
      // file:"sensitiveWords.txt",
      calendarTitle: "",
      setCalendarVisible: false,
      videoVisible: false,
      options3: {
        disabledDate (date) {
          return date && date.valueOf() < Date.now() - 86400000;
        }
      },
      scheduleForm: {
        pageNumber: 1,
        pageSize: 10,
        goodsId: "",
        goodTypeEnum: "GOOD"
      },
      festivalForm: {
        pageNumber: 1,
        pageSize: 10,
        goodsId: "",
        goodTypeEnum: "GOOD"
      },
      specialTotal: 0,
      presideVisible: false,
      addPresideVisible: false,
      presideTitle: "",
      festivalTitle: "",
      addSpecialVisible: false,
      specialVisible: false,
      timeTitle: "",
      timeVisible: false,
      setVisible: false,
      siteSpecifitionlist: [],
      siteTitle: "",
      siteVisible: false,
      loading: true,
      visible: false,
      lookPreVisible: false,
      preVisible: false,
      imgSrc: "",
      pageTotal: 0, //总条数
      drop: false, //搜索栏
      modalVisible: false, //模态框的显示隐藏
      publicData: [],
      lookServiceVisible: false,
      serviceVisible: false,
      serviceType: 0,
      commentVisible: false,
      replyVisible: false,
      replyForm: {
        pid: "",
        content: ""
      },
      replyFormValidate: {
        content: [{ required: true, message: "不能为空", trigger: "blur" }],
      },
      commentColumns: [
        {
          type: "index",
          width: 60,
          align: "center",
          fixed: "left"
        },
        {
          title: "用户头像",
          minWidth: 90,
          sortable: false,
          key: "avatar",
          render: (h, params) => {
            return h("avatar", {
              props: {
                src: params.row.avatar
              }
            });
          }
        },  
        {
          title: "用户昵称",
          minWidth: 120,
          sortable: false,
          key: "nickName"
        },
        {
          title: "购买规格",
          minWidth: 90,
          sortable: false,
          key: "itemAttrKeys",
          render: (h,params)=> {
            let str = ""
            str = params.row.itemAttrKeys.join("/");
            return h("span", str)
          }
        },
        {
          title: "评论星级",
          minWidth: 90,
          sortable: false,
          key: "startLevel",
          render:(h,params)=> {
            return h("span", params.row.startLevel+"星")
          }
        },
        {
          title: "评论内容",
          minWidth: 120,
          sortable: false,
          key: "content"
        },
        {
          title: "评论图片",
          minWidth: 120,
          sortable: false,
          key: "pics",
          render: (h, params) => {
            let imgs = params.row.pics;
            return h('div',imgs.map(item=>{
              return h('img',  {
                attrs: {
                  src: item, 
                  style: 'width: 40px;height: 40px;margin-right:5px'
                },
                on: {
                  click: ()=> {
                    this.handleView(item)
                  }
                }
              },);
            })
            )
          }
        },
        {
          title: "商家回复",
          minWidth: 120,
          sortable: false,
          key: "reply"
        },
        {
          title: "创建时间",
          minWidth: 120,
          sortable: false,
          key: "createTime"
        },
        {
          title: "操作",
          width: 150,
          align: "center",
          fixed: "right",
          render: (h, params) => {
            return h("div", [
              h(
                "Button",
                {
                  props: {
                    type: "info",
                    size: "small"
                  },
                  style: {
                    marginRight: "5px",
                    display: (params.row.type === 0) ? "inline-block" : "none"
                  },
                  on: {
                    click: () => {
                      this.showReply(params.row);
                    }
                  }
                },
                "回复评论"
              ),
              h(
                "Button",
                {
                  props: {
                    type: "error",
                    size: "small"
                  },
                  style: {
                    marginRight: "5px",
                    display: (params.row.type === 1) ? "inline-block" : "none"
                  },
                  on: {
                    click: () => {
                      this.removeComment(params.row,1);
                    }
                  }
                },
                "删除回复"
              ),
            ]);
          }
        }
      ],
      commentFrom: {
        goodId: "",
      },
      commentData: [],
      // commentTotal: 0,
      modalType: "add", //add: 添加商品     edit编辑商品
      modalTitle: "添加商品",
      commodityData: [],
      category: [],
      color: [],
      size: [],
      loadingEdit: false,
      serviceSearchForm: {
        goodsId: "",
        pageNumber: 1,
        pageSize: 10
      },
      serviceForm: {
        id: "",
        goodsId: "",
        serverName: ""
      },
      serviceFormValidate: {
        serverName: [{ required: true, message: "请输入服务名称", trigger: "blur" },
        { validator: validateName, trigger: "blur" }],
      },
      seiviceColumns: [
        {
          type: "index",
          width: 60,
          align: "center",
          fixed: "left"
        },
        {
          title: "服务名称",
          minWidth: 120,
          sortable: false,
          key: "serverName"
        },
        {
          title: "操作",
          width: 200,
          align: "center",
          fixed: "right",
          render: (h, params) => {
            return h("div", [
              h(
                "Button",
                {
                  props: {
                    type: "info",
                    size: "small",
                    icon: "ios-create-outline"
                  },
                  style: {
                    marginRight: "5px"
                  },
                  on: {
                    click: () => {
                      this.editService(params.row);
                    }
                  }
                },
                "编辑"
              ),
              h(
                "Button",
                {
                  props: {
                    type: "error",
                    size: "small",
                    icon: "md-trash"
                  },
                  style: {
                    marginRight: "5px",
                  },
                  on: {
                    click: () => {
                      this.removeService(params.row,1);
                    }
                  }
                },
                "删除"
              ),
            ]);
          }
        }
      ],
      serviceData: [],
      serviceTotal: 0,
      //商品显示
      commodityColumns: [
        {
          type: "index",
          width: 60,
          align: "center",
          fixed: "left"
        },
        {
          title: "商品名称",
          minWidth: 120,
          sortable: false,
          key: "goodName"
        }, 
        {
          title: "商品图片",
          minWidth: 120,
          sortable: false,
          key: "goodPics",
          render: (h, params) => {
            var imgs = params.row.goodPics.split(",");
            return h("img", {
              attrs: {
                src: imgs[0]
              },
              style: {
                width: "30px",
                height: "30px"
              },
              on: {
                click: ()=> {
                  this.handleView(imgs[0])
                }
              }
            });
          }
        }, 
        {
          title: "视频展示图",
          minWidth: 120,
          sortable: false,
          key: "goodVideoPic",
          render: (h, params) => {
            return h("img", {
              attrs: {
                src: params.row.goodVideoPic
              },
              style: {
                width: "30px",
                height: "30px"
              },
              on: {
                click: ()=> {
                  this.handleView(params.row.goodVideoPic)
                }
              }
            });
          }
        },
        {
          title: "商品视频",
          minWidth: 120,
          sortable: false,
          key: "goodVideo",
          render: (h, params) => {
            return h("video",
                {
                  style: {
                    cursor: "pointer",
                    width: "80px",
                    height: "60px",
                    margin: "10px 0",
                    "object-fit": "contain"
                  },
                  on: {
                    click: () => {
                      this.showVideo(params.row);
                    }
                  }
                },
                [
                  h("source", {
                    attrs: {
                      src: params.row.goodVideo
                    }
                  })
                ]
              );
          }
        },      
        {
          title: "商品原价",
          minWidth: 120,
          sortable: false,
          key: "goodOldPrice"
        },
        {
          title: "商品现价",
          minWidth: 120,
          sortable: false,
          key: "goodNewPrice"
        },
        {
          title: "分类名称",
          minWidth: 120,
          sortable: false,
          key: "goodCategoryName"
        },
        {
          title: "是否推荐",
          minWidth: 120,
          sortable: false,
          key: "recommend",
          render: (h,params)=> {
            if (params.row.recommend === 0) {
              return h("sapn","否")
            } else {
              return h("sapn","是")
            }
          }
        },
        {
          title: "购买状态",
          minWidth: 120,
          sortable: false,
          key: "buyState",
          render: (h,params) => {
            if (params.row.buyState === 1) {
              return h("span", "可购买")
            } else if (params.row.buyState === 2) {
              return h ("span", "可租赁")
            } else if (params.row.buyState === 3) {
              return h ("span", "可购买和租赁")
            }
          }
        },
        {
          title: "租赁状态",
          minWidth: 120,
          sortable: false,
          key: "leaseState",
          render: (h,params) => {
            if (params.row.leaseState === 1) {
              return h ("span", "线上支付尾款")
            } else if (params.row.leaseState === 2) {
              return h ("span", "线下支付尾款")
            }
          }
        },
        {
          title: "创建时间",
          minWidth: 120,
          sortable: false,
          key: "createTime"
        },        
        {
          title: "操作",
          width: 420,
          align: "center",
          fixed: "right",
          render: (h, params) => {
            return h("div", [
              h(
                "Button",
                {
                  props: {
                    type: "info",
                    size: "small"
                  },
                  style: {
                    marginRight: "5px"
                  },
                  on: {
                    click: () => {
                      this.edit(params.row);
                    }
                  }
                },
                "编辑"
              ),
              h(
                "Button",
                {
                  props: {
                    type: "error",
                    size: "small",
                  },
                  style: {
                    marginRight: "5px",
                    display:(params.row.delFlag==0)?"inline-block":"none"
                  },
                  on: {
                    click: () => {
                      this.remove(params.row,1);
                    }
                  }
                },
                "下架"
              ),
              h(
                "Button",
                {
                  props: {
                    type: "default",
                    size: "small"
                  },
                  style: {
                    marginRight: "5px",
                    display:(params.row.delFlag==1)?"inline-block":"none"
                  },
                  on: {
                    click: () => {
                      this.remove(params.row,2);
                    }
                  }
                },
                "上架"
              ),
              h(
                "Button",
                {
                  props: {
                    type: "primary",
                    size: "small"
                  },
                  style: {
                    marginRight: "5px",
                    display: (this.service !== "四大金刚") ? "inline-block" : "none"
                  },
                  on: {
                    click: () => {
                      this.showSpecification(params.row);
                    }
                  }
                },
                "商品规格"
              ),
              h(
                "Button",
                {
                  props: {
                    type: "primary",
                    size: "small"
                  },
                  style: {
                    marginRight: "5px",
                    display: (this.service === "四大金刚") ? "inline-block" : "none"
                  },
                  on: {
                    click: () => {
                      this.showSpecialFestival(params.row);
                    }
                  }
                },
                "特殊节日"
              ),
              h(
                "Button",
                {
                  props: {
                    type: "primary",
                    size: "small"
                  },
                  style: {
                    marginRight: "5px",
                    display: (this.service === "四大金刚") ? "inline-block" : "none"
                  },
                  on: {
                    click: () => {
                      this.showSchedule(params.row);
                    }
                  }
                },
                "无档期时间"
              ),
              h(
                "Button",
                {
                  props: {
                    type: "info",
                    size: "small"
                  },
                  style: {
                    marginRight: "5px"
                  },
                  on: {
                    click: () => {
                      this.showService(params.row);
                    }
                  }
                },
                "商品服务"
              ),
              h(
                "Button",
                {
                  props: {
                    type: "default",
                    size: "small"
                  },
                  style: {
                    marginRight: "5px"
                  },
                  on: {
                    click: () => {
                      this.showComment(params.row);
                    }
                  }
                },
                "查看评论"
              ),
              h(
                "Button",
                {
                  props: {
                    type: "info",
                    size: "small"
                  },
                  style: {
                    marginRight: "5px",
                    display: (params.row.recommend === 0) ? "inline-block" : "none"
                  },
                  on: {
                    click: () => {
                      this.recommendCommodities(params.row);
                    }
                  }
                },
                "推荐商品"
              ),
              h(
                "Button",
                {
                  props: {
                    type: "default",
                    size: "small"
                  },
                  style: {
                    marginRight: "5px",
                    display: (params.row.recommend === 1) ? "inline-block" : "none"
                  },
                  on: {
                    click: () => {
                      this.removeRecommend(params.row);
                    }
                  }
                },
                "取消推荐"
              ),
            ]);
          }
        }
      ],
      siteForm: {
        siteName: "",
        siteItemValue: "",
        sitePics: "",
        sitePrice: "",
        categoryId: "",
        goodCategoryName: ""
      },
      formValidate: {
        siteName: [ { required: true, message: "请输入场地名称", trigger: "blur" },
          { validator: validateName, trigger: "blur" },
          { type: 'string', max: 20, message: '场地名称不能多于20字', trigger: 'blur' }],
        siteItemValue: [{ required: true, message: "不能为空", trigger: "change" }],
        categoryId: [{ required: true, message: "请选择分类", trigger: "change" }],
        sitePics: [{ required: true, message: "不能为空", trigger: "change", type: "array" }],
        sitePrice: [{ required: true, message: "请输入商品现价", trigger: "blur", pattern:/^(([1-9]\d{0,9})|0)(\.\d{0,2})?$/ },
                    { required: true, message: "商品现价格式不正确",pattern:/^(([1-9]\d{0,9})|0)(\.\d{0,2})?$/}],
      },
      data: [],
      total: 0,
      columns: [
        {
          type: "index",
          width: 60,
          align: "center",
          fixed: "left"
        },
        {
          title: "场地名称",
          minWidth: 120,
          sortable: false,
          key: "siteName"
        },
        {
          title: "场地规格参数",
          minWidth: 120,
          sortable: false,
          key: "siteItemValue",
          render: (h,params) => {
            var arr = params.row.siteItemValue;
              // console.log(arr);
              var str = "";
              var arr2 = [];
              arr.forEach((item2,index)=> {
                arr2.push(h("div",[
                  h("span","规格"+(index+1)+"："),
                  h("span",item2.attrValue)
                ]))
              })
              return h("div", arr2)
          }
        },
        {
          title: "场地价格",
          minWidth: 120,
          sortable: false,
          key: "sitePrice"
        },
        {
          title: "所属分类",
          minWidth: 120,
          sortable: false,
          key: "categoryName"
        },
        {
          title: "是否推荐",
          minWidth: 120,
          sortable: false,
          key: "recommend"
        },
        {
          title: "场地介绍图片",
          minWidth: 120,
          sortable: false,
          key: "sitePics",
          render: (h,params) => {
            let imgs = params.row.sitePics;
            return h('div',imgs.map(item=>{
              return h('img',  {
                attrs: {
                  src: item, 
                  style: 'width: 40px;height: 30px;margin-right:5px'
                },
                on: {
                  click: ()=> {
                    this.handleView(item)
                  }
                }
              },);
            })
            )
          }
        }, 
        {
          title: "创建时间",
          minWidth: 120,
          sortable: false,
          key: "createTime"
        },
        {
          title: "操作",
          key: "action",
          align: "center",
          fixed: "right",
          width: 420,
          render: (h, params) => {
            return h("div", [
              h(
                "Button",
                {
                  props: {
                    type: "primary",
                    size: "small",
                    icon: "ios-create-outline"
                  },
                  style: {
                    marginRight: "5px",
                  },
                  on: {
                    click: () => {
                      this.editSite(params.row);
                    }
                  }
                },
                "编辑"
              ),
              h(
                "Button",
                {
                  props: {
                    type: "error",
                    size: "small",
                  },
                  style: {
                    marginRight: "5px"
                  },
                  on: {
                    click: () => {
                      this.removeSite(params.row);
                    }
                  }
                },
                "删除"
              ),
              h(
                "Button",
                {
                  props: {
                    type: "default",
                    size: "small",
                  },
                  style: {
                    "marginRight": "5px"
                  },
                  on: {
                    click: () => {
                      this.setTime(params.row);
                    }
                  }
                },
                "设置无档期时间"
              ),
              h(
                "Button",
                {
                  props: {
                    type: "info",
                    size: "small",
                  },
                  style: {
                    "marginRight": "5px"
                  },
                  on: {
                    click: () => {
                      this.setCalendar(params.row);
                    }
                  }
                },
                "设置档期价格"
              ),
              h(
                "Button",
                {
                  props: {
                    type: "primary",
                    size: "small",
                  },
                  style: {
                    "marginRight": "5px",
                    display: (params.row.recommend === "否") ? "inline-block" : "none"
                  },
                  on: {
                    click: () => {
                      this.recommendSite(params.row,1);
                    }
                  }
                },
                "推荐场所"
              ),
              h(
                "Button",
                {
                  props: {
                    type: "default",
                    size: "small",
                  },
                  style: {
                    "marginRight": "5px",
                    display: (params.row.recommend === "是") ? "inline-block" : "none"
                  },
                  on: {
                    click: () => {
                      this.recommendSite(params.row,2);
                    }
                  }
                },
                "取消推荐"
              ),
            ]);
          }
        }
      ],
      timeForm: {
        id: "",
        siteId: "",
        noScheduleTime: "",
        dayTimeType: ""
      },
      timeFormValidate: {
        noScheduleTime: [{ required: true, message: "请选择无档期时间", trigger: "change" }],
        dayTimeType: [{ required: true, message: "请选择档期时间段", trigger: "change" }],
      },
      timeData: [],
      timeColumns: [
        {
          type: "index",
          width: 60,
          align: "center",
          fixed: "left"
        },
        {
          title: "无档期时间",
          minWidth: 120,
          sortable: false,
          key: "noScheduleTime"
        },
        {
          title: "无档期时间段",
          minWidth: 120,
          sortable: false,
          key: "dayTimeType"
        },
        {
          title: "操作",
          key: "action",
          align: "center",
          width: 280,
          render: (h, params) => {
            return h("div", [
              h(
                "Button",
                {
                  props: {
                    type: "primary",
                    size: "small",
                    icon: "ios-create-outline"
                  },
                  style: {
                    marginRight: "5px",
                  },
                  on: {
                    click: () => {
                      this.editTime(params.row);
                    }
                  }
                },
                "编辑"
              ),
              h(
                "Button",
                {
                  props: {
                    type: "error",
                    size: "small",
                  },
                  style: {
                    marginRight: "5px"
                  },
                  on: {
                    click: () => {
                      this.removeTime(params.row);
                    }
                  }
                },
                "删除"
              ),
            ]);
          }
        }
      ],
      searchForm: {
        shopName: "", // 店铺名称
        goodName: "", // 商品名称
        goodCategoryId: "",
        goodCategoryName: "",
        pageNumber: 1,
        pageSize: 10
      },
      addForm: {
        goodCategoryId: "",
        goodName: "",
        goodPics: "",
        goodDetails: "",
        goodOldPrice: "",
        goodNewPrice: "",
        typeEnum: "GOOD",
        goodVideoPic: "",
        goodVideo: ""
      },
      formRules: {
        goodName: [
          { required: true, trigger: "blur", message: "请输入商品名称" },
          { validator: validateName, trigger: "blur" },
          { type: 'string', max: 30, message: '商品名称不能多于30字', trigger: 'blur' }],
        goodCategoryId: [{ required: true, message: "请选择商品分类", trigger: "change" }],
        goodPics: [
          { required: true, message: "请选择商品轮播", trigger: "blur", type: "array" },
          { type: 'array', max: 5, min: 3, message: '商品轮播最少3张，最多5张', trigger: 'blur' }],
        goodVideoPic: [{ required: true, message: "请选择视频展示图", trigger: "blur" }],
        goodVideo: [{ required: true, message: "请选择商品轮播", trigger: "blur" }],
        goodNewPrice: [{ required: true, message: "请输入商品原价", trigger: "blur", pattern:/^(([1-9]\d{0,9})|0)(\.\d{0,2})?$/ },
                    { required: true, message: "商品原价格式不正确",pattern:/^(([1-9]\d{0,9})|0)(\.\d{0,2})?$/}],
        goodOldPrice: [{ required: true, message: "请输入商品现价", trigger: "blur", pattern:/^(([1-9]\d{0,9})|0)(\.\d{0,2})?$/ },
                    { required: true, message: "商品现价格式不正确",pattern:/^(([1-9]\d{0,9})|0)(\.\d{0,2})?$/}],
        // integral: [ { required: true, message: "商品积分只能为正整数", trigger: "blur", pattern: /(^[1-9]\d*$)/ }],
      },
      preForm: {
        id: "",
        goodsId: "",
        attrSymbolPath: "",
        goodPrice: "",
        inventory: 0,
        pic: "",
        goodDeposit: "0",
        // goodDalancePayment: ""
      },
      submitLoading: false,
      specificationlist: [],
      preFormValidate: {
        attrSymbolPath: [{ required: true, message: "请选择规格", trigger: "change" }],
        goodPrice: [{ required: true, message: "请输入规格价格", trigger: "blur", pattern:/^(([1-9]\d{0,9})|0)(\.\d{0,2})?$/ },
                    { required: true, message: "规格价格格式不正确",pattern:/^(([1-9]\d{0,9})|0)(\.\d{0,2})?$/}],
        inventory: [{ required: true, message: "请输入库存", trigger: "blur", type: "number" },
                    { required: true, message: "规格库存只能为正整数", trigger: "blur", type: "number" }],
        pic: [{ required: true, message: "请选择图片", trigger: "blur" }],
        goodDeposit: [{ required: false, message: "请输入规格定金", trigger: "blur", pattern:/^(([1-9]\d{0,9})|0)(\.\d{0,2})?$/ },
                    { required: false, message: "规格定金格式不正确",pattern:/^(([1-9]\d{0,9})|0)(\.\d{0,2})?$/}],
        // goodDalancePayment: [{ required: true, message: "请输入规格价格", trigger: "blur", pattern:/^(([1-9]\d{0,9})|0)(\.\d{0,2})?$/ },
        //             { required: true, message: "规格价格格式不正确",pattern:/^(([1-9]\d{0,9})|0)(\.\d{0,2})?$/}],
      },
      specificationData: [],
      specificationColumns: [
        {
          type: "index",
          width: 60,
          align: "center",
          fixed: "left"
        },
        {
          title: "规格名称",
          key: "attrSymbolPathName",
        },
        {
          title: "规格价格",
          key: "goodPrice",
        },
        {
          title: "规格定金",
          key: "goodDeposit",
        },
        // {
        //   title: "规格尾款",
        //   key: "goodDalancePayment",
        // },
        {
          title: "规格图片",
          key: "pic",
          sortable: false,
          render: (h, params) =>{
            return h('img',{
              attrs:{
                src:params.row.pic,
                onerror:'this.src="https://goss.veer.com/creative/vcg/veer/800water/veer-133632476.jpg"'
              },
              style:{
                width:'42px',
                verticalAlign:'middle',
              },
              on: {
                click: ()=> {
                  this.handleView(params.row.pic)
                }
              }
            })
          }
        },
        {
          title: "库存",
          key: "inventory"
        },
        {
          title: "操作",
          key: "action",
          align: "center",
          width: 180,
          render: (h, params) => {
            return h("div", [
              h(
                "Button",
                {
                  props: {
                    type: "primary",
                    size: "small",
                    icon: "ios-create-outline"
                  },
                  style: {
                    marginRight: "5px",
                  },
                  on: {
                    click: () => {
                      this.editSpecification(params.row);
                    }
                  }
                },
                "编辑"
              ),
              h(
                "Button",
                {
                  props: {
                    type: "error",
                    size: "small",
                  },
                  on: {
                    click: () => {
                      this.removeSpecification(params.row);
                    }
                  }
                },
                "删除"
              ),
            ]);
          }
        }
      ],
      attrIdArr: [],
      goodId: "",
      modalStatus: 0,
      classifyData: [],
      classId: "",
      buyState: 0,
      siteShow: false,
      service: "",
      specialFestivalData: [],
      specialFestivalColumns: [
        {
          type: "index",
          width: 60,
          align: "center",
          fixed: "left"
        },
        {
          title: "特殊节日日期",
          minWidth: 120,
          sortable: false,
          key: "scheduleTime"
        },
        {
          title: "特殊节日时间",
          minWidth: 120,
          sortable: false,
          key: "dayTimeType"
        },
        {
          title: "特殊节日价格",
          minWidth: 120,
          sortable: false,
          key: "goodsPrice"
        },
        {
          title: "操作",
          key: "action",
          align: "center",
          width: 280,
          render: (h, params) => {
            return h("div", [
              h(
                "Button",
                {
                  props: {
                    type: "primary",
                    size: "small",
                    icon: "ios-create-outline"
                  },
                  style: {
                    marginRight: "5px",
                  },
                  on: {
                    click: () => {
                      this.editFestival(params.row);
                    }
                  }
                },
                "编辑"
              ),
              h(
                "Button",
                {
                  props: {
                    type: "error",
                    size: "small",
                  },
                  style: {
                    marginRight: "5px"
                  },
                  on: {
                    click: () => {
                      this.removeFestival(params.row);
                    }
                  }
                },
                "删除"
              ),
            ]);
          }
        }
      ],
      specialFestivalForm: {
        id: "",
        // dayTimeType: "",
        scheduleTime: "",
        goodsPrice: "",
        goodsId: "",
        goodTypeEnum: "GOOD"
      },
      specialFestivalRules: {
        // dayTimeType: [{ required: true, message: "请选择时间段", trigger: "change" }],
        scheduleTime: [{ required: true, message: "请选择特殊节日", trigger: "change" }],
        goodsPrice: [{ required: true, message: "请输入特殊节日价格", trigger: "blur", pattern:/^(([1-9]\d{0,9})|0)(\.\d{0,2})?$/ },
                    { required: true, message: "特殊节日价格式不正确",pattern:/^(([1-9]\d{0,9})|0)(\.\d{0,2})?$/}],
      },
      presideForm: {
        goodsId: "",
        goodTypeEnum: "GOOD",
        dayTimeType: "",
        noScheduleTime: ""
      },
      presideData: [],
      presideRules: {
        dayTimeType: [{ required: true, message: "请选择时间段", trigger: "change" }],
        noScheduleTime: [{ required: true, message: "请选择特殊节日", trigger: "change" }],
      },
      presideColumns: [
        {
          type: "index",
          width: 60,
          align: "center",
          fixed: "left"
        },
        {
          title: "无档期日期",
          minWidth: 120,
          sortable: false,
          key: "noScheduleTime"
        },
        {
          title: "无档期时间",
          minWidth: 120,
          sortable: false,
          key: "dayTimeType"
        },
        {
          title: "创建时间",
          minWidth: 120,
          sortable: false,
          key: "createTime"
        },
        {
          title: "操作",
          key: "action",
          align: "center",
          width: 280,
          render: (h, params) => {
            return h("div", [
              h(
                "Button",
                {
                  props: {
                    type: "primary",
                    size: "small",
                    icon: "ios-create-outline"
                  },
                  style: {
                    marginRight: "5px",
                  },
                  on: {
                    click: () => {
                      this.editPreside(params.row);
                    }
                  }
                },
                "编辑"
              ),
              h(
                "Button",
                {
                  props: {
                    type: "error",
                    size: "small",
                  },
                  style: {
                    marginRight: "5px"
                  },
                  on: {
                    click: () => {
                      this.removePreside(params.row);
                    }
                  }
                },
                "删除"
              ),
            ]);
          }
        }
      ],
      calendarForm: {
        id: "",
        siteId: "",
        scheduleTime: "",
        sitePrice: ""
      },
      calendarFormRules: {
        scheduleTime: [{ required: true, message: "请选择档期时间", trigger: "change" }],
        sitePrice: [{ required: true, message: "请输入档期价格", trigger: "blur", pattern:/^(([1-9]\d{0,9})|0)(\.\d{0,2})?$/ },
                    { required: true, message: "档期价格格式不正确",pattern:/^(([1-9]\d{0,9})|0)(\.\d{0,2})?$/}],
      },
      calendarVisible: false,
      calendarData: [],
      calendarSearchForm: {
        siteId: "",
        pageNumber: 1,
        pageSize: 10
      },
      calendarColumns: [
        {
          type: "index",
          width: 60,
          align: "center",
          fixed: "left"
        },
        {
          title: "档期日期",
          minWidth: 120,
          sortable: false,
          key: "scheduleTime"
        },
        {
          title: "档期时间段",
          minWidth: 120,
          sortable: false,
          key: "dayTimeType"
        },
        {
          title: "档期价格",
          minWidth: 120,
          sortable: false,
          key: "sitePrice"
        },
        {
          title: "创建时间",
          minWidth: 120,
          sortable: false,
          key: "createTime"
        },
        {
          title: "操作",
          key: "action",
          align: "center",
          width: 280,
          render: (h, params) => {
            return h("div", [
              h(
                "Button",
                {
                  props: {
                    type: "primary",
                    size: "small",
                    icon: "ios-create-outline"
                  },
                  style: {
                    marginRight: "5px",
                  },
                  on: {
                    click: () => {
                      this.editCalendar(params.row);
                    }
                  }
                },
                "编辑"
              ),
              h(
                "Button",
                {
                  props: {
                    type: "error",
                    size: "small",
                  },
                  style: {
                    marginRight: "5px"
                  },
                  on: {
                    click: () => {
                      this.removeCalendar(params.row);
                    }
                  }
                },
                "删除"
              ),
            ]);
          }
        }
      ]
    };
  },
  methods: {
    recommendSite (v, k) {
      var text = "";
      k === 1 ? text = "推荐" : text = "取消推荐"
      this.$Modal.confirm({
        title: text,
        content: "确认"+text+"该场地吗？",
        loading: true,
        onOk: ()=> {
          var data = {
            id: v.id
          }
          this.postRequest("/site/updateSiteRecommend", data).then(res=> {
            if (res.success) {
              this.$Message.success(text+"成功");
              this.getSiteList();
              this.$Modal.remove()
            } else {
              this.$Message.error(res.message);
              this.$Modal.remove()
            }
          })
        }
      })
    },
    showVideo(v) {
      dp = new DPlayer({
        container: document.getElementById("dplayer"),
        screenshot: true,
        video: {
          url: v.goodVideo
        },
      });
      this.videoVisible = true;
    },
    closeVideo() {
      dp.destroy();
    },
    showSpecification (v) {
      this.goodId = v.id;
      this.classId = v.goodCategoryId;
      // (v.buyState === 3) ? (this.require = true) : (this.require = false)
      this.buyState = v.buyState;
      var data = {
        goodsId: this.goodId
      }
      this.postRequest("/sizeAndRolor/getWebInventory", data).then(res=> {
        if (res.success) {
          var arr = res.result.data;
          for(let val of arr){
            for(let i in val){
              (val[i] === null) ? (val[i] = "-") : ""
            }
          }
          this.specificationData = res.result.data;
        } else {
          this.specificationData = []
        }
      })
      this.lookPreVisible = true;
    },

    // 展示特殊节日列表
    showSpecialFestival (v) {
      this.specialFestivalForm.goodsId = v.id;
      this.festivalForm.goodsId = v.id;
      this.loading = true;
      this.postRequest("/compereAuctionCalendar/PcGetCompereAuctionCalendar", this.festivalForm).then(res=> {
        this.loading = false;
        if (res.success) {
          this.specialFestivalData = res.result.data;
          this.specialTotal = res.result.size;
        } else {
          this.specialFestivalData = [];
          this.specialTotal = 0;
        }
      })
      this.specialVisible = true;
    },

    // 添加特殊节日
    addSpecialFesitval () {
      this.festivalTitle = "添加特殊节日";
      this.$refs.specialFestivalForm.resetFields()
      this.modalType = "add";
      this.addSpecialVisible = true;
      delete this.specialFestivalForm.id;
    },

    // 编辑特殊节日
    editFestival (v) {
      this.festivalTitle = "编辑特殊节日";
      this.modalType = "edit";
      this.specialFestivalForm.scheduleTime = v.scheduleTime;
      this.specialFestivalForm.goodsPrice = v.goodsPrice;
      this.addSpecialVisible = true;
    },

    removeFestival (v) {
      this.$Modal.confirm({
        title: "删除",
        content: "确认删除该数据吗？",
        loading: false,
        onOk: ()=> {
          var data = {
            goodsId: this.festivalForm.goodsId,
            scheduleTime: v.scheduleTime
          }
          this.postRequest("/compereAuctionCalendar/removeCompereAuctionCalendar", data).then(res=> {
            this.loading = false;
            if (res.success) {
              this.$Message.success("删除成功");
              this.postRequest("/compereAuctionCalendar/PcGetCompereAuctionCalendar", this.festivalForm).then(res=> {
                if (res.success) {
                  this.specialFestivalData = res.result.data;
                  this.specialTotal = res.result.size;
                  this.$forceUpdate()
                } else {
                  this.specialFestivalData = [];
                  this.specialTotal = 0;
                }
              })
              this.$Modal.remove();
            } else {
              this.$Message.error(res.message);
              this.$Modal.remove();
            }
          })
        }
      })
    },

    specialHandleSubmit () {
      this.$refs.specialFestivalForm.validate(valid=> {
        if (valid) {
          console.log(valid)
          this.submitLoading = true;
          // if (this.modalType === "add") {
            this.postRequest("/compereAuctionCalendar/insertOrderUpdateCompereAuctionCalendar",  this.specialFestivalForm).then(res=> {
              this.submitLoading = false;
              if (res.success) {
                this.$Message.success("添加成功");
                this.loading = true;
                this.postRequest("/compereAuctionCalendar/PcGetCompereAuctionCalendar", this.festivalForm).then(res=> {
                  this.loading = false;
                  if (res.success) {
                    this.specialFestivalData = res.result.data;
                    this.specialTotal = res.result.size;
                    this.$forceUpdate()
                  } else {
                    this.specialFestivalData = [];
                    this.specialTotal = 0
                  }
                })
                this.addSpecialVisible = false;
              } else {
                this.$Message.error(res.message);
                this.addSpecialVisible = false;
              }
            })
          // } else {

          // }
        }
      })
    },

    // 展示无档期列表
    showSchedule (v) {
      this.presideForm.goodsId = v.id;
      this.scheduleForm.goodsId = v.id
      this.loading = true;
      this.postRequest("/compereNoCalendars/PcGetCompereNoCalendars", this.scheduleForm).then(res=> {
        this.loading = false;
        if (res.success) {
          this.presideData = res.result.data;
        } else {
          this.presideData = []
        }
      });
      this.presideVisible = true;
    },

    addPreside () {
      this.presideTitle = "添加无档期数据";
      this.$refs.presideForm.resetFields();
      this.addPresideVisible = true;
      delete this.presideForm.id;
    },

    editPreside (v) {
      this.presideTitle = "编辑无档期数据";
      this.presideForm.noScheduleTime = v.noScheduleTime;
      (v.dayTimeType == "上午") ? (this.presideForm.dayTimeType = "A_M") : (this.presideForm.dayTimeType = "P_M")
      this.presideForm.id = v.id;
      this.addPresideVisible = true;
    },

    removePreside (v) {
      this.$Modal.confirm({
        title: "删除",
        content: "确认删除该数据吗？",
        loading: false,
        onOk: ()=> {
          var data = {
            id: v.id
          }
          this.postRequest("/compereNoCalendars/removeCompereNoCalendars", data).then(res=> {
            this.loading = false;
            if (res.success) {
              this.$Message.success("删除成功");
              this.loading = true;
              this.postRequest("/compereNoCalendars/PcGetCompereNoCalendars", this.scheduleForm).then(res=> {
                this.loading = false;
                if (res.success) {
                  this.presideData = res.result.data;
                } else {
                  this.presideData = []
                }
              })
              this.$Modal.remove();
            } else {
              this.$Message.error(res.message);
              this.$Modal.remove();
            }
          })
        }
      })
    },

    specialHandleSubmit () {
      this.$refs.specialFestivalForm.validate(valid=> {
        if (valid) {
          console.log(valid)
          this.submitLoading = true;
          // if (this.modalType === "add") {
            this.postRequest("/compereAuctionCalendar/insertOrderUpdateCompereAuctionCalendar",  this.specialFestivalForm).then(res=> {
              this.submitLoading = false;
              if (res.success) {
                this.$Message.success("添加成功");
                this.loading = true;
                this.postRequest("/compereAuctionCalendar/PcGetCompereAuctionCalendar", this.festivalForm).then(res=> {
                  this.loading = false;
                  if (res.success) {
                    this.specialFestivalData = res.result.data;
                    this.specialTotal = res.result.size;
                    this.$forceUpdate()
                  } else {
                    this.specialFestivalData = [];
                    this.specialTotal = 0
                  }
                })
                this.addSpecialVisible = false;
              } else {
                this.$Message.error(res.message);
                this.addSpecialVisible = false;
              }
            })
          // } else {

          // }
        }
      })
    },

    // 展示无档期列表
    showSchedule (v) {
      this.presideForm.goodsId = v.id;
      this.scheduleForm.goodsId = v.id
      this.loading = true;
      this.postRequest("/compereNoCalendars/PcGetCompereNoCalendars", this.scheduleForm).then(res=> {
        this.loading = false;
        if (res.success) {
          this.presideData = res.result.data;
        } else {
          this.presideData = []
        }
      });
      this.presideVisible = true;
    },

    presideHandleSubmit () {
      this.$refs.presideForm.validate(valid=> {
        if (valid) {
          this.submitLoading = true;
          this.postRequest("/compereNoCalendars/insertOrderUpdateCompereNoCalendars", this.presideForm).then(res=> {
            this.submitLoading = false;
            if (res.success) {
              this.$Message.success("操作成功");
              this.loading = true;
              this.postRequest("/compereNoCalendars/PcGetCompereNoCalendars", this.scheduleForm).then(res=> {
                this.loading = false;
                if (res.success) {
                  this.presideData = res.result.data;
                } else {
                  this.presideData = []
                }
              })
              this.addPresideVisible = false
            } else {
              this.$Message.error(res.message);
              this.addPresideVisible = false
            }
          })
        }
      })
    },

    // 添加商品服务
    showService (v) {
      this.serviceSearchForm.goodsId = v.id;
      this.serviceForm.goodsId = v.id;
      this.loading = true;
      this.postRequest("/goodService/getGoodsServiceList", this.serviceSearchForm).then(res=> {
        this.loading = false;
        if (res.success) {
          this.serviceData = res.result.data;
          // this.serviceTotal = res.result.size;
        } else {
          this.serviceData = [];
          // this.serviceTotal = 0;
          this.$Message.error(res.message)
        }
      })
      this.lookServiceVisible = true;
    },

    addService () {
      this.$refs.serviceForm.resetFields()
      this.postRequest("/goodService/getShopServiceList").then(res=> {
        if (res.success) {
          this.publicData = res.result.data;
        }
      })
      this.serviceVisible = true;
      this.serviceType = 0;
    },

    editService (v) {
      this.serviceForm.id = v.id;
      this.serviceForm.serverName = v.serverName;
      this.serviceVisible = true;
      this.serviceType = 1;
    },

    removeSite (v) {
      this.$Modal.confirm({
        title: "删除",
        content: "确认删除所选数据吗？",
        loading: true,
        onOk: ()=> {
          var data = {
            ids: v.id
          }
          this.postRequest("/site/removeSite",data).then(res=> {
            this.loading = false;
            if (res.success) {
              this.$Message.success("删除成功");
              this.getSiteList();
              this.$Modal.remove();
            } else {
              this.$Message.success(res.message);
              this.$Modal.remove();
            }
          })
        }
      })
    },

    setTime (v) {
      this.timeForm.siteId = v.id;
      var data = {
        siteId: v.id
      }
      this.postRequest("/siteAuctionCalendar/getSiteNoAuctionCalendar", data).then(res=> {
        if (res.success) {
          this.timeData = res.result
        } else {
          this.timeData = []
        }
      })
      this.timeVisible = true;
    },

    setCalendar (v) {
      this.calendarSearchForm.siteId = v.id;
      this.calendarForm.siteId = v.id;
      this.postRequest("/sitePrice/getSitePrice", this.calendarSearchForm).then(res=> {
        if (res.success) {
          this.calendarData = res.result;
        } else {
          this.calendarData = []
        }
      })
      this.calendarVisible = true;
    },

    addTime () {
      this.timeTitle = "添加档期";
      this.modalType = "add";
      delete this.timeForm.id;
      this.$refs.timeForm.resetFields();
      this.setVisible = true;
    },

    addCalendar () {
      this.calendarTitle = "添加档期";
      this.modalType = "add";
      delete this.calendarForm.id;
      this.$refs.calendarForm.resetFields();
      this.setCalendarVisible = true;
    },

    editTime (v) {
      this.timeTitle = "编辑档期";
      this.modalType = "edit";
      this.timeForm.id = v.id;
      (v.dayTimeType == "上午") ? (this.timeForm.dayTimeType = "A_M") : (this.timeForm.dayTimeType = "P_M")
      this.timeForm.noScheduleTime = v.noScheduleTime;
      this.setVisible = true;
    },

    editCalendar (v) {
      this.calendarTitle = "编辑档期";
      this.modalType = "edit";
      // this.calendarForm.id = v.id;
      this.calendarForm.scheduleTime = v.scheduleTime;
      this.calendarForm.sitePrice = v.sitePrice;
      this.setCalendarVisible = true;
    },

    removeTime (v) {
      this.$Modal.confirm({
        title: "删除",
        content: "确定删除所选数据吗？",
        loading: true,
        onOk: ()=> {
          var data = {
            ids: v.id
          }
          this.postRequest("/siteAuctionCalendar/removeSiteAuctionCalendar", data).then(res=> {
            if (res.success) {
              this.$Message.success("删除成功");
              var data2 = {
                siteId: this.timeForm.siteId
              }
              this.postRequest("/siteAuctionCalendar/getSiteNoAuctionCalendar", data2).then(res=> {
                if (res.success) {
                  this.timeData = res.result
                } else {
                  this.timeData = []
                }
              })
              this.$Modal.remove()
            } else {
              this.$Message.success(res.message);
              this.$Modal.remove()
            }
          })
        }
      })
    },

    removeCalendar (v) {
      this.$Modal.confirm({
        title: "删除",
        content: "确定删除所选数据吗？",
        loading: true,
        onOk: ()=> {
          var data = {
            siteId: this.calendarForm.siteId,
            scheduleTime: v.scheduleTime
          }
          this.postRequest("/sitePrice/removeSitePrice", data).then(res=> {
            if (res.success) {
              this.$Message.success("删除成功");
              this.postRequest("/sitePrice/getSitePrice", this.calendarSearchForm).then(res=> {
                if (res.success) {
                  this.calendarData = res.result;
                } else {
                  this.calendarData = []
                }
              })
              this.$Modal.remove()
            } else {
              this.$Message.success(res.message);
              this.$Modal.remove()
            }
          })
        }
      })
    },

    calendarSubmit () {
      this.$refs.calendarForm.validate(valid=> {
        if (valid) {
          this.submitLoading = true;
          if (this.modalType = "add") {
            this.postRequest("/sitePrice/insertOrderUpdateSitePrice",this.calendarForm).then(res=> {
              this.submitLoading = false;
              if (res.success) {
                this.$Message.success("操作成功");
                this.postRequest("/sitePrice/getSitePrice", this.calendarSearchForm).then(res=> {
                  if (res.success) {
                    this.calendarData = res.result;
                  } else {
                    this.calendarData = []
                  }
                })
                this.setCalendarVisible = false;
              } else {
                this.$Message.error(res.message);
                this.setCalendarVisible = false;
              }
            })
          } else {
            this.postRequest("/sitePrice/insertOrderUpdateSitePrice",this.calendarForm).then(res=> {
              this.submitLoading = false;
              if (res.success) {
                this.$Message.success("操作成功");
                this.postRequest("/sitePrice/getSitePrice", this.calendarSearchForm).then(res=> {
                  if (res.success) {
                    this.calendarData = res.result;
                  } else {
                    this.calendarData = []
                  }
                })
                this.setCalendarVisible = false;
              } else {
                this.$Message.error(res.message);
                this.setCalendarVisible = false;
              }
            })
          }
        }
      })
    },

    serviceHandleSubmit () {
      this.$refs.serviceForm.validate(valid=> {
        if (valid) {
          this.submitLoading = true;
          if (this.serviceType === 0) {
            delete this.serviceForm.id;
            this.postRequest("/goodService/insertOrderUpdateGoodService", this.serviceForm).then(res=> {
              this.submitLoading = false;
              if (res.success) {
                this.$Message.success("操作成功");
                this.serviceVisible = false;
                this.loading = true;
                this.postRequest("/goodService/getGoodsServiceList", this.serviceSearchForm).then(res2=> {
                  this.loading = false;
                  if (res2.success) {
                    this.serviceData = res2.result.data;
                    // this.serviceTotal = res2.result.size;
                  } else {
                    this.serviceData = [];
                    // this.serviceTotal = 0;
                    this.$Message.error(res2.message)
                  }
                })
              } else {
                this.$Message.error(res.message);
                this.serviceVisible = false;
              }
            })
          } else {
            this.postRequest("/goodService/insertOrderUpdateGoodService", this.serviceForm).then(res=> {
              this.submitLoading = false;
              if (res.success) {
                this.$Message.success("操作成功");
                this.serviceVisible = false;
                this.loading = true;
                this.postRequest("/goodService/getGoodsServiceList", this.serviceSearchForm).then(res2=> {
                  this.loading = false;
                  if (res2.success) {
                    this.serviceData = res2.result.data;
                    // this.serviceTotal = res2.result.size;
                  } else {
                    this.serviceData = [];
                    // this.serviceTotal = 0;
                    this.$Message.error(res2.message)
                  }
                })
              } else {
                this.$Message.error(res.message);
                this.serviceVisible = false;
              }
            })
          }
        }
      })
    },

    removeService (v) {
      this.$Modal.confirm({
        title: "删除",
        content: "确认删除该条数据吗？",
        loading: true,
        onOk: ()=> {
          var data = {
            ids: v.id
          }
          this.postRequest("/goodService/removeGoodService", data).then(res=> {
            this.loading = false;
            if (res.success) {
              this.$Message.success("删除成功");
              this.$Modal.remove()
              this.loading = true;
              this.postRequest("/goodService/getGoodsServiceList", this.serviceSearchForm).then(res2=> {
                this.loading = false;
                if (res2.success) {
                  this.serviceData = res2.result.data;
                } else {
                  this.serviceData = [];
                  this.$Message.error(res2.message)
                }
              })
            } else {
              this.$Message.error(res.message);
              this.$Modal.remove()
            }
          })
        }
      })
    },

    showComment (v) {
      this.commentFrom.goodId = v.id;
      this.commentVisible = true;
      this.loading = true;
      this.postRequest("/comment/PcGetGoodsComment", this.commentFrom).then(res=> {
        this.loading = false;
        if (res.success) {
          var arr = res.result;
          for(let val of arr){
            for(let i in val){
              (val[i] === null) ? (val[i] = "-") : ""
            }
          }
          this.commentData = res.result;
        } else {
          this.commentData = [];
        }
      })
    },

    recommendCommodities (v) {
      this.$Modal.confirm({
        title: "推荐",
        content: "确认推荐该商品吗？",
        loading: true,
        onOk: ()=> {
          var data = {
            goodId: v.id
          }
          this.postRequest("/recommendedPackage/insertOrderUpdateRecommendedPackage", data).then(res=> {
            this.loading = false;
            if (res.success) {
              this.$Message.success("推荐成功");
              this.getList();
              this.$Modal.remove()
            } else {
              this.$Message.error(res.message);
              this.$Modal.remove()
            }
          })
        }
      })
    },

    removeRecommend (v) {
      this.$Modal.confirm({
        title: "取消推荐",
        content: "确认取消推荐该商品吗？",
        loading: true,
        onOk: ()=> {
          var data = {
            ids: v.id
          }
          this.postRequest("/recommendedPackage/removeRecommendedPackage", data).then(res=> {
            this.loading = false;
            if (res.success) {
              this.$Message.success("取消推荐成功");
              this.getList();
              this.$Modal.remove()
            } else {
              this.$Message.error(res.message);
              this.$Modal.remove()
            }
          })
        }
      })
    },

    replyHandleSubmit () {
      this.$refs.replyForm.validate(valid=> {
        if (valid) {
          this.submitLoading = true;
          this.postRequest("/comment/replyComment", this.replyForm).then(res=> {
            this.submitLoading = false;
            if (res.success) {
              this.$Message.success("操作成功");
              this.$refs.replyForm.resetFields()
              this.replyVisible = false;
              this.loading = true;
              this.postRequest("/comment/PcGetGoodsComment", this.commentFrom).then(res2=> {
                this.loading = false;
                if (res2.success) {
                  this.commentData = res2.result;
                } else {
                  this.$Message.error(res2.message)
                  this.commentData = [];
                }
              })
            } else {
              this.$Message.error(res.message);
              this.replyVisible = false;
            }
          })
        }
      })
    },

    showReply (v) {
      this.$refs.replyForm.resetFields()
      this.replyForm.pid = v.id;
      this.replyVisible = true;
    },

    removeComment (v) {
      this.$Modal.confirm({
        title: "删除",
        content: "确认删除该条商家回复吗？",
        loading: true,
        onOk: ()=> {
          var data = {
            ids: v.shopCommentId
          }
          this.postRequest("/comment/removeComment", data).then(res=> {
            this.loading = false;
            if (res.success) {
              this.$Message.success("删除成功");
              this.$Modal.remove()
              this.loading = true;
              this.postRequest("/comment/PcGetGoodsComment", this.commentFrom).then(res2=> {
                this.loading = false;
                if (res2.success) {
                  this.commentData = res2.result;
                  this.$forceUpdate()
                } else {
                  this.commentData = res2.result;
                  this.$Message.error(res2.message)
                }
              })
            } else {
              this.$Message.error(res.message);
              this.$Modal.remove()
            }
          })
        }
      })
    },

    changeSelect (v) {
      console.log(v)
    },

    changeSort () {

    },

    addSpecification () {
      this.modalStatus = 0;
      this.$refs.preForm.resetFields();
      this.attrIdArr = []
      this.specificationlist = []
      this.preForm.attrSymbolPath = "";
      var data = {
        classId: this.classId,
      }
      this.postRequest("/itemAttrKey/getItemAttrKeyList", data).then(res=> {
        if (res.success) {
          this.specificationlist = res.result;
          this.preVisible = true;
        } else {
          this.specificationlist = [];
          this.$Message.warning("该商品所属分类下没有规格属性，请先去添加规格属性！")
        }
      })
    },

    cancelModal () {
      this.specificationlist = [];
      this.preVisible = false;
    },

    selectSpecification (e, k) {
      for(var i=0; i<k+1; i++) {
        if (i == k) {
          this.attrIdArr[k] = e
          console.log('id==='+this.attrIdArr[k])
        }
      }
      var str = this.attrIdArr.join(',');
      if (str.substr(0,1)==',') {
        this.preForm.attrSymbolPath = str.substr(1);
      } else {
        this.preForm.attrSymbolPath = str
      }
      console.log(this.preForm.attrSymbolPath)
    },

    selectSite (e, k) {
      console.log(e);
      console.log(k);
      for(var i=0; i<k+1; i++) {
        if (i == k) {
          this.attrIdArr[k] = e
          console.log('id==='+this.attrIdArr[k])
        }
      }
      var str = this.attrIdArr.join(",");
      if (str.substr(0,1)==',') {
        this.siteForm.siteItemValue = str.substr(1);
      } else {
        this.siteForm.siteItemValue = str
      }
      console.log(this.siteForm.siteItemValue)
    },

    editSite (v) {
      this.siteTitle ="修改场地";
      this.modalType = "edit"
      this.siteForm.id = v.id;
      this.siteForm.siteName = v.siteName;
      this.siteForm.sitePrice = v.sitePrice;
      this.siteForm.categoryId = v.categoryId;
      this.siteForm.goodCategoryName = v.categoryName;
      var array = [];
      v.siteItemValue.forEach(item=> {
        array.push(item.id)
      })
      this.siteForm.siteItemValue = array.join(",")
      if (v.goodPics === null) {

      } else {
        this.$refs.sitesUpload.uploadList = [];
        this.$refs.sitesUpload.setData(v.sitePics);
      }
      this.siteVisible = true;
    },

    changeSetTime (event) {
      this.timeForm.noScheduleTime = event;
    },

    changeSpecialTime (event) {
      this.specialFestivalForm.scheduleTime = event;
    },

    changeRresideTime (event) {
      this.presideForm.noScheduleTime = event;
    },

    changeSetCalendar (event) {
      this.calendarForm.scheduleTime = event;
    },

    siteHandleSubmit () {
      this.$refs.siteForm.validate(valid=> {
        if (valid) {
          this.submitLoading = true;
          if (this.modalType === "add") {
            var array1 = [];
            this.$refs.sitesUpload.uploadList.forEach(item1=> {
              array1.push(item1.url)
            })
            this.siteForm.sitePics = array1.join(",");
            this.postRequest("/site/insertOrderUpdateSite", this.siteForm).then(res=> {
              this.submitLoading = false;
              if (res.success) {
                this.$Message.success("操作成功");
                this.getSiteList();
                this.siteVisible = false
              } else {
                this.$Message.success(res.message);
                this.siteVisible = false
              }
            })
          } else {
            var array1 = [];
            this.$refs.sitesUpload.uploadList.forEach(item1=> {
              array1.push(item1.url)
            })
            this.siteForm.sitePics = array1.join(",");
            this.postRequest("/site/insertOrderUpdateSite", this.siteForm).then(res=> {
              this.submitLoading = false;
              if (res.success) {
                this.$Message.success("操作成功");
                this.getSiteList();
                this.siteVisible = false
              } else {
                this.$Message.success(res.message);
                this.siteVisible = false
              }
            })
          }
        }
      })
    },

    setHandleSubmit () {
      this.$refs.timeForm.validate(valid=> {
        if (valid) {
          if (this.modalType == "add") {
            delete this.timeForm.id;
            this.postRequest("/siteAuctionCalendar/insertOrderUpdateSiteAuctionCalendar", this.timeForm).then(res=> {
              if (res.success) {
                this.$Message.success("添加成功");
                var data = {
                  siteId: this.timeForm.siteId
                }
                this.postRequest("/siteAuctionCalendar/getSiteNoAuctionCalendar", data).then(res=> {
                  if (res.success) {
                    this.timeData = res.result
                  } else {
                    this.timeData = []
                  }
                })
                this.setVisible = false
              }
            })
          } else {
            this.postRequest("/siteAuctionCalendar/insertOrderUpdateSiteAuctionCalendar", this.timeForm).then(res=> {
              if (res.success) {
                this.$Message.success("编辑成功");
                var data = {
                  siteId: this.timeForm.siteId
                }
                this.postRequest("/siteAuctionCalendar/getSiteNoAuctionCalendar", data).then(res=> {
                  if (res.success) {
                    this.timeData = res.result
                  } else {
                    this.timeData = []
                  }
                })
                this.setVisible = false
              }
            })
          }
        }
      })
    },

    preHandleSubmit () {
      this.$refs.preForm.validate(valid=> {
        if (valid) {
          console.log(valid)
          if (this.modalStatus === 0) {
            delete this.preForm.id;
            this.preForm.goodsId = this.goodId;
            console.log(this.preForm)
            this.postRequest("/sizeAndRolor/insertOrderUpdateSizeAndRolor", this.preForm).then(res=> {
              if (res.success) {
                this.$Message.success("操作成功");
                this.preVisible = false;
                this.$refs.preForm.resetFields();
                this.attrIdArr = [];
                // this.
                var param = {
                  goodsId: this.goodId
                }
                this.postRequest("/sizeAndRolor/getWebInventory", param).then(res=> {
                  if (res.success) {
                    this.specificationData = res.result.data;
                  } else {
                    this.specificationData = []
                  }
                })
              }
            })
          } else {
            this.preForm.goodsId = this.goodId;
            console.log(this.preForm)
            this.postRequest("/sizeAndRolor/insertOrderUpdateSizeAndRolor", this.preForm).then(res=> {
              if (res.success) {
                this.$Message.success("操作成功");
                this.preVisible = false;
                this.$refs.preForm.resetFields();
                this.attrIdArr = [];
                var param = {
                  goodsId: this.goodId
                }
                this.postRequest("/sizeAndRolor/getWebInventory", param).then(res=> {
                  if (res.success) {
                    this.specificationData = res.result.data;
                  } else {
                    this.specificationData = []
                  }
                })
              }
            })
          }
        }
      })
    },
    // 编辑商品规格库存
    editSpecification (v) {
      console.log(v);
      this.modalStatus = 1;
      this.preForm.id = v.id;
      this.preForm.inventory = v.inventory;
      this.preForm.goodPrice = v.goodPrice;
      this.preForm.attrSymbolPath = v.attrSymbolPath;
      this.preForm.pic = v.pic;
      this.preForm.goodDeposit = v.goodDeposit;
      // this.preForm.goodDalancePayment = v.goodDalancePayment;
      this.preVisible = true;
    },

    removeSpecification (v) {
      this.$Modal.confirm({
        title: "确认删除",
        content: "您确认要删除所选的规格数据?",
        loading: true,
        onOk: () => {
          var param = {
            ids: v.id
          }
          // 批量删除
          this.postRequest("/sizeAndRolor/removeSizeAndRolor",param).then(res => {
            this.$Modal.remove();
            if (res.success) {
              this.$Message.success("操作成功");
              this.$Modal.remove();
              var data = {
                goodsId: this.goodId
              }
              this.postRequest("/sizeAndRolor/getWebInventory", data).then(res=> {
                if (res.success) {
                  this.specificationData = res.result.data;
                } else {
                  this.specificationData = []
                }
              })
            }
          });
        }
      });
    },

    // 获取分类列表
    getCategory() {
      this.postRequest("/goodCategory/getBackStoreCategoryList").then(res=> {
        if (res.success) {
          res.result.forEach(function(e) {
            e.title=e.title;
              if (e.havaNext) {
                e.loading = false;
                e.children = [];
              }
            });
          this.classifyData = res.result;
        }
      })
    },

    loadData(item, callback) { 
        // 异步加载树子节点数据
      var param ={
        pid:item.id
      }
      this.postRequest("/goodCategory/getGoodCategoryList",param).then(res => {
        if (res.success) {
          res.result.forEach(function(e) {
            e.title=e.title
            if (e.isParent) {
              e.loading = false;
              e.children = [];
            }
          });
          callback(res.result);
        }
      });
    },

    selectTwoTreeEdit(v){
      console.log(v);
      if (v[0].parentId === "0") {
        this.$Message.warning("添加或修改商品只能选择子节点")
      } else {
        var data = {
          pid:v[0].id
        }
        this.addForm.goodCategoryId = v[0].id;
        this.addForm.goodCategoryName = v[0].title;
        this.$forceUpdate();
      }
    },

    selectSiteEdit (v) {
      if (v[0].parentId === "0") {
        this.$Message.warning("添加或修改场地只能选择子节点")
      } else {
        var data = {
          pid:v[0].id
        }
        this.siteForm.categoryId = v[0].id;
        this.siteForm.goodCategoryName = v[0].title;
        this.$forceUpdate();
      }
    },

    selectOneTreeEdit(v){
      var data = {
        pid:v[0].id
      }
      this.searchForm.goodCategoryId = v[0].id;
      this.searchForm.goodCategoryName = v[0].title;
      this.$forceUpdate();
    },
    
    clearIpt () {
      this.searchForm.goodCategoryId = "";
      this.searchForm.goodCategoryName = "";
      let data = this.$refs.treeOne.getSelectedNodes()[0];
      if (data) {
        data.selected = false;
      }
      this.searchForm.shopName = "";
      this.searchForm.goodName = "";
    },

    // 获取商品列表
    getList() {
      this.siteShow = true
      this.loading = true;
      this.postRequest("/good/PCgoodsList", this.searchForm).then(res=> {
        this.loading = false
        if (res.success) {
          this.commodityData = res.result.data;
          this.pageTotal = res.result.size
        } else {
          this.commodityData = [];
          this.pageTotal = 0
        }
      })
    },

    // 获取场地列表
    getSiteList () {
      this.siteShow = false;
      this.loading = true;
      this.postRequest("/site/getBackSiteListVo", this.searchForm).then(res=> {
        this.loading = false;
        if (res.success) {
          this.data = res.result.dataResult;
          this.total = res.result.totalSize;
          // consol.log(res.result.totalSize)
        } else {
          this.data = [];
          this.total = 0;
        }
      })
    },

    // 编辑商品
    edit(row) {
      console.log(row);
      this.modalVisible = true;
      this.modalType = "edit";
      this.modalTitle = "编辑商品";
      this.addForm.id = row.id;
      this.addForm.goodCategoryId = row.goodCategoryId;
      this.addForm.goodCategoryName = row.goodCategoryName;
      this.addForm.goodName = row.goodName;
      this.addForm.goodNewPrice = row.goodNewPrice;
      this.addForm.goodOldPrice = row.goodOldPrice;
      // this.addForm.integral = row.integral;
      if (row.goodPics === null) {

      } else {
        this.$refs.picsUpload.uploadList = [];
        var array = row.goodPics.split(",")
        this.$refs.picsUpload.setData(array);
      }
      this.addForm.goodVideoPic = row.goodVideoPic;
      this.addForm.goodVideo = row.goodVideo;
      this.$refs.editor.setData(row.goodDetails);
    },
    // 添加商品
    showAddModal() {
      // 添加商品不需要商品的id
      if (this.siteShow) {
        delete this.addForm.id;
        if (this.service != "四大金刚") {
          let data = this.$refs.treeTwo.getSelectedNodes()[0];
          if (data) {
            data.selected = false;
          }
          this.addForm.goodCategoryId = "";
          this.addForm.goodCategoryName = "";
        } else {
          this.addForm.goodCategoryId = JSON.parse(this.getStore("userInfo")).classId;
        }
        
        this.$refs.addForm.resetFields()
        this.addForm.goodPics = "";
        // this.addForm.integral = "";
        this.addForm.goodVideo = "";
        var data1 = "";
        this.$refs.editor.setData(data1);
        this.$refs.picsUpload.uploadList = [];
        this.modalVisible = true;
        this.modalType = "add";
        this.modalTitle = "添加商品";
      } else {
        this.$refs.sitesUpload.uploadList = [];
        this.$refs.siteForm.resetFields();
        this.siteForm.categoryId = JSON.parse(this.getStore("userInfo")).classId;
        this.siteTitle = "添加场地";
        this.siteForm.categoryId = "";
        this.siteForm.goodCategoryName = "";
        let data = this.$refs.treeTwo.getSelectedNodes()[0];
        if (data) {
          data.selected = false;
        }
        this.modalType = "add";
        delete this.siteForm.id;
        this.siteVisible = true;
        this.siteSpecifitionlist = [];
        this.attrIdArr = [];
        this.postRequest("/sizeAndRolor/gerRceptionhotelCategory").then(res=> {
        if (res.success) {
          this.siteSpecifitionlist = res.result;
        } else {
          this.siteSpecifitionlist = []
        }
      })
      }
    },
    // 删除商品
    remove(v,k) {
      
          removeCommodity({
            id: v.id
          }).then(res => {
            if(res.success) {
              this.$Message.success('操作成功')
              this.getList();
              this.$Modal.remove()
            }else{
              this.$Message.error('操作失败');
              this.$Modal.remove()
            }
          })
        
    },
    // 切换页
    changePage(num) {
        this.searchForm.pageNumber = num
        this.getList()
    },
    changeFestivalPage(num) {
      this.festivalForm.pageNumber = num
      this.postRequest("/compereAuctionCalendar/PcGetCompereAuctionCalendar", this.festivalForm).then(res=> {
        this.loading = false;
        if (res.success) {
          this.specialFestivalData = res.result.data;
          this.specialTotal = res.result.size;
        } else {
          this.specialFestivalData = [];
          this.specialTotal = 0;
        }
      })
    },
    // 切换每页显示条数
    changePageSize (num) {
        this.searchForm.pageSize = num;
        this.getList()
    },
    changeFestivalPageSize (num) {
      this.festivalForm.pageSize = num
      this.postRequest("/compereAuctionCalendar/PcGetCompereAuctionCalendar", this.festivalForm).then(res=> {
        this.loading = false;
        if (res.success) {
          this.specialFestivalData = res.result.data;
          this.specialTotal = res.result.size;
        } else {
          this.specialFestivalData = [];
          this.specialTotal = 0;
        }
      })
    },
    // 放大图片
    handleView(src) {
      this.visible = true;
      this.imgSrc = src;
    },
    // modal取消按钮
    cancel() {
      this.modalVisible = false;
    },
    // 提交表单，添加、编辑都调用这个
    handleSubmit() {
      this.$refs.addForm.validate(valid => {
        if (valid) {
          // 获取要添加的数据
          if (Number(this.addForm.goodNewPrice) > Number(this.addForm.goodOldPrice)) {
            this.$Message.warning("商品现价不可以高于商品原价");
          } else if (this.$refs.picsUpload.uploadList.length < 3) {
            this.$Message.warning("商品轮播图片不能少于3张！");
          } else if (this.$refs.picsUpload.uploadList.length > 5) {
            this.$Message.warning("商品轮播图片不能多于5张！");
          } else {
            this.submitLoading = true;
            if (this.modalType === "add") {
              delete this.addForm.id;
              //  添加
              var array1 = [];
              this.$refs.picsUpload.uploadList.forEach(item1=> {
                array1.push(item1.url)
              })
              console.log(this.addForm.goodCategoryId)
              this.addForm.goodPics = array1.join(",");
              this.postRequest("/good/insertOrderUpdateGood", this.addForm).then(res=> {
                this.submitLoading = false;
                if (res.success) {
                  this.$Message.success("操作成功");
                  this.modalVisible = false;
                  this.getList();
                } else {
                  this.modalVisible = false;
                  this.$Message.error(res.message);
                }
              })
            } else {
              //  编辑
              var array1 = [];
              this.$refs.picsUpload.uploadList.forEach(item1=> {
                array1.push(item1.url)
              })
              this.addForm.goodPics = array1.join(",")
              this.postRequest("/good/insertOrderUpdateGood", this.addForm).then(res=> {
                this.submitLoading = false
                if (res.success) {
                  this.$Message.success("操作成功");
                  this.modalVisible = false;
                  this.getList();
                } else {
                  this.modalVisible = false;
                  this.$Message.error(res.message);
                }
              })
            }
          }
        }
      })
    },
    // aaa () {
    //   // https://fanshafuoss.oss-cn-beijing.aliyuncs.com/3eedd610d4ac4cd3b7ccbc19130e0d28.txt
    //   var reader = new FileReader();//这是核心！！读取操作都是由它完成的
    //     reader.readAsText('https://fanshafuoss.oss-cn-beijing.aliyuncs.com/3eedd610d4ac4cd3b7ccbc19130e0d28.txt');
    //     reader.onload = function(oFREvent){//读取完毕从中取值
    //         var pointsTxt = oFREvent.target.result;
    //         alert(pointsTxt)
    //         // your code。。。。
    //     }
    // },
    init () {
      var str = JSON.parse(this.getStore("userInfo")).serviceCategoryName;
      this.service = str;
      // console.log(this.service)

      if (str=="婚宴酒店") {
        this.siteForm.categoryId = JSON.parse(this.getStore("userInfo")).classId;
        this.getSiteList()
      } else if (str==="四大金刚"){
        this.addForm.goodCategoryId = JSON.parse(this.getStore("userInfo")).classId;
        console.log(this.addForm.goodCategoryId)
        this.getList()
      } else {
        this.getList()
      }

      // this.aaa()
      // this.aaa()
      // (str=="婚宴酒店") ? this.getSiteList() : this.getList()
    },
  },
  created() {
    this.getCategory();
    this.init();
  }
};
</script>

<style>
.commodity-content {
  padding: 16px;
  background-color: #ffffff;
}
.itemInput {
  width: 160px;
}
.selected {
  width: 50%;
}
.imgModal {
  text-align: center;
}
.img {
  width: 50px;
  height: 50px;
}
.page{
        margin: 16px;
        overflow: hidden;
        text-align: right;
    }
</style>